﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace ImaginationFactory.Dialogs
{
    /// <summary>
    /// ColorPassage.xaml 的交互逻辑
    /// </summary>
    public partial class ColorPassageDialog : Window
    {
        MainWindow mWindowTemp;
        double r;
        double g;
        double b;

        public ColorPassageDialog( MainWindow mWindow )
        {

            InitializeComponent();
            mWindowTemp = mWindow;
            r = 0;
            g = 0;
            b = 0;
        }

        private void bScr_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {
            b = bScr.Value;
        }

        private void gScr_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {
            g = gScr.Value;
        }

        private void rScr_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {
            r = rScr.Value;
        }

        private void rItem_Selected(object sender, RoutedEventArgs e)
        {
            rScr.Value = 0;
        }

        private void gItem_Selected(object sender, RoutedEventArgs e)
        {
            gScr.Value = 0;
        }

        private void bItem_Selected(object sender, RoutedEventArgs e)
        {
            bScr.Value = 0;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if ( r != 0 )
                mWindowTemp.ImageLibrary.ChannelMixer( ColorPassage.ColorPassage_red, r );
            if( g != 0)
                mWindowTemp.ImageLibrary.ChannelMixer(ColorPassage.ColorPassage_green, g);
            if ( b != 0 )
                mWindowTemp.ImageLibrary.ChannelMixer(ColorPassage.ColorPassage_blue, b);

            mWindowTemp.image.Source = mWindowTemp.ImageLibrary.LoadedImage.Source;
            //mListBox.colorPassageItem.IsSelected = false;
            r = 0;
            g = 0;
            b = 0;
            rScr.Value = 0;
            gScr.Value = 0;
            bScr.Value = 0;
            this.Close();
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            //mListBox.colorPassageItem.IsSelected = false;
            this.Close();
        }

        private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            this.DragMove();
        }
    }
}
